package com.viewsky.base.back.controller.example;

import java.util.Map;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.viewsky.base.back.bean.Result;
import com.viewsky.base.back.controller.BaseController;
import com.viewsky.base.back.util.Constant;
import com.viewsky.base.back.util.Converter;

@RestController
public class FormController extends BaseController
{
	@PostMapping(value="/test-form")
	public Result testForm(@RequestBody Map<String, Object> mapParam)throws Exception
	{		
		Result result = new Result();
		
		try
		{				
			logger.info(Converter.toJson(mapParam));
			
			result.setServer(getServer());
			result.setCode(Constant.ResultCode.SUCCESS);
			result.setData(mapParam);
		}
		catch(Exception e)
		{
			String strMessage = "服务器：" + getServer() +
					"，POST方式/test-form，" +
					"表单实例报错：" + e.toString();
			
			logger.error(strMessage);			
			throw new Exception(strMessage);
		}
		
		return result;
	}
}
